import numpy as np
from skimage import io
from config import *
import os


MEAN_VALUES = np.array([123.68, 116.779, 103.939]).reshape((1, 1, 3))


def saveImg(imgBatch, cursor=0, name=''):
    try:
        for k, i in enumerate(range(batch_size)):
            img = imgBatch[i,:,:,:]
            img = img * (255 / 2) + MEAN_VALUES
            img[img > 255] = 255
            img[img < 0] = 0
            img = img.astype(np.uint8)

            if not os.path.exists("./test/"):
                os.mkdir("./test/")
                print("create the directory: ./test/")
            io.imsave('./test' % (name, k + cursor), img)
    except IndexError as e:
        pass
